<html xmlns="http://www.w3.org/1999/xhtml"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:p="http://primefaces.org/ui">
<h:head>
</h:head>
<h:body>

	<ui:composition template="/templates/templateListar.xhtml">
		<ui:define name="conteudo">
			<ui:param name="actionBean" value="#{alunoMB}" />
			<p:growl id="mensagem" showDetail="true" autoUpdate="false"
				closable="true" />


			<h:form id="frmAluno">

				<p:hotkey bind="esc"
					handler="document.getElementById('frmAluno:btnCancelar').click()" />

				<p:fieldset legend="Cadastro de Aluno" toggleable="true"
					collapsed="false" toggleSpeed="500">

					<h:panelGrid columns="1">
						<p:commandButton action="#{alunoMB.prepararIncluir}" value="Novo">

						</p:commandButton>

						<p:commandButton id="btnCancelar" action="#{alunoMB.sair}"
							style="display:none" immediate="true" value="sair">

						</p:commandButton>

					</h:panelGrid>
				</p:fieldset>
			</h:form>
			<h:form id="frmTab">
				<p:dataTable id="tabela" var="item" value="#{alunoMB.lista}"
					paginator="true" rows="50" emptyMessage="Não há registros na lista"
					paginatorTemplate="{CurrentPageReport}  {FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink} {RowsPerPageDropdown}"
					rowsPerPageTemplate="10,15,25,50,100">
					<f:facet name="header">Alunos</f:facet>
					<p:column headerText="Matricula" style="width: 10%;"
						sortBy="#{item.matricula}">
						<h:outputText value="#{item.matricula}" />
					</p:column>
					<p:column headerText="Nome" style="width: 25%;"
						sortBy="#{item.nome}">
						<h:outputText value="#{item.nome}" />
					</p:column>
					<p:column headerText="Telefone" style="width: 25%;"
						sortBy="#{item.telefone}">
						<h:outputText value="#{item.telefone}" />
					</p:column>
					<p:column headerText="E-mail" style="width: 25%;"
						sortBy="#{item.email}">
						<h:outputText value="#{item.email}" />
					</p:column>

					<p:column headerText="Ação" width="15%">

						<div align="center">
							<p:commandLink action="#{alunoMB.prepararAlterar}"
								title="Alterar">
								<p:graphicImage value="/imagens/alt_1.jpg" />
								<f:setPropertyActionListener value="#{item}"
									target="#{alunoMB.alunoSelecionado}" />
							</p:commandLink>

							<p:commandLink action="#{alunoMB.prepararConsultar}"
								title="Consultar">
								<p:graphicImage value="/imagens/busca_4.jpg" />
								<f:setPropertyActionListener value="#{item}"
									target="#{alunoMB.alunoSelecionado}" />
							</p:commandLink>

							<p:commandLink action="#{alunoMB.excluir}" title="Excluir"
								update=":formExcluir:Excluir" oncomplete="confirmation.show()"
								immediate="false">
								<p:graphicImage value="/imagens/exc_1.jpg" />
								<f:setPropertyActionListener value="#{item}"
									target="#{alunoMB.alunoSelecionado}" />
							</p:commandLink>
						</div>
					</p:column>


				</p:dataTable>
			</h:form>

			<ui:include src="/includes/confirmacaoExcluir.xhtml" />
		</ui:define>
	</ui:composition>
</h:body>
</html>